package com.example.tabbar.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.example.tabbar.databinding.ItemPermissionBinding
import com.example.tabbar.room.entity.Print

class PrintSelectAdapter : RecyclerView.Adapter<PrintSelectAdapter.ViewHolder>() {
    private var permissions: MutableList<Print> = ArrayList()
    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): PrintSelectAdapter.ViewHolder {
        val binding = ItemPermissionBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return ViewHolder(binding)
    }

    override fun onBindViewHolder(holder: PrintSelectAdapter.ViewHolder, position: Int) {
        val permission = permissions[position]
        holder.checkBox.text = permission.name
    }

    override fun getItemCount(): Int {
        return permissions.size
    }
    fun setItems(items: List<Print>?) {
        permissions.clear()
        if (items != null) {
            permissions.addAll(items)
        }
        notifyDataSetChanged()
    }

    class ViewHolder(binding: ItemPermissionBinding) : RecyclerView.ViewHolder(binding.root) {
        var checkBox = binding.permission
    }


}